package com.aloda.controller.admin;

import com.aloda.dto.CategoryPageDTO;
import com.aloda.result.PageResult;
import com.aloda.result.Result;
import com.aloda.service.CategoryService;
import com.aloda.vo.CategoryQueryVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/category")
@Slf4j
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    /**
     * 商品分类分页查询
     * @param categoryPageDTO
     * @return
     */
    @PostMapping("/list")
    public Result<PageResult> pageQuery(@RequestBody CategoryPageDTO categoryPageDTO){
        log.info("商品分类分页查询：{}",categoryPageDTO);
        PageResult pageResult = categoryService.pageQuery(categoryPageDTO);
        return Result.success(pageResult);
    }

    /**
     * 商品页分类选择框查询
     * @return
     */
    @GetMapping("/query")
    public Result<List<CategoryQueryVO>> query(){
        List<CategoryQueryVO> list = categoryService.query();
        return Result.success(list);
    }
}
